//
//  AppDelegate.m
//  UI03_UIViewController_CustomView
//
//  Created by wyx on 16/3/11.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "MyView.h"
#import "LTView.h"

@interface AppDelegate ()

@end

@implementation AppDelegate
-(void)dealloc{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    self.window.backgroundColor = [UIColor cyanColor];
    //创建 controller 对象.
    ViewController *vc = [[ViewController alloc] init];
    //指定 window 跟视图控制器(进入 App 之后看到第一界面)
    //逻辑代码和 UI 基本都是在 controller中编写
    //详见 ViewController.m 文件
    self.window.rootViewController = vc;
    [_window release];
    [vc release];
    //[self homework];
    //[self createCustomView];
    
    return YES;
}
#pragma mark - 作业
- (void)homework {
    MyView *view = [[MyView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    view.backgroundColor = [UIColor cyanColor];
    [self.window addSubview:view];
    //动画
    [UIView animateWithDuration:3 animations:^{
        view.frame = CGRectMake(200, 200, 200, 200);
    }];
    [view release];
}
#pragma mark - 知识点1: 自定义 View(LTView)
- (void)createCustomView {
    //创建对象
    LTView *viewOfUser = [[LTView alloc] initWithFrame:CGRectMake(20, 40,self.window.frame.size.width - 40 , 40) withText:@"   用户名:" placeHolder:@"请输入用户名"];
    [self.window addSubview:viewOfUser];
    viewOfUser.backgroundColor = [UIColor lightGrayColor];
    [viewOfUser release];
    //passwd
    LTView *viewOfpasswd = [[LTView alloc] initWithFrame:CGRectMake(20, 110, self.window.frame.size.width - 40, 40) withText:@"   密码:" placeHolder:@"请输入密码"];
    viewOfpasswd.backgroundColor =[UIColor lightGrayColor];
    [self.window addSubview:viewOfpasswd];
    [viewOfpasswd release];
}
#pragma mark - 知识点2: 视图控制器 UIViewController
/** 详见, self.window 创建代码段 */
#pragma mark - 知识点3: 视图控制器的生命周期
/** 详见 ViewController.m文件 */
#pragma mark - 知识点4: viewController 推出页面
/** 详见, ViewController 和 VCOfSecond 类*/

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
